'''
Created on 2010-10-28

@author: Administrator
'''
import MySQLdb
from DBUtils import PooledDB
from config import db


pool = PooledDB.PooledDB(MySQLdb,10,host=db['host'],user=db['user'],passwd=db['passwd'],db=db['db'])


def getConn():
    """example:
       conn = DB.getConn()
       cur = conn.Cursor()
       cur.execute("insert into xxx values('%s','%s')" % ( 1 , '23'))"""
    return pool.connection()


def getCur():
    conn = getConn()
    cur = conn.cursor()
    return cur


def getMSCur():
    import pymssql
    conn = pymssql.connect(host='localhost', user='root', password='yyh', database='temp')
    cur = conn.cursor()

if __name__ =="__main__":
    conn = getConn()
    cur = conn.cursor()
    count = cur.execute("select * from detailsession")
    print count
    for i in range(count):  
        t = cur.fetchone()
        print t
